from db import Session
from db.bidding import AdminShop


def insertAdminShop(AdminShopList):
    """
    一次插入多条数据
    :param AdminShopList:
    :return:
    """
    session = Session()
    try:
        for adminshop in AdminShopList:
            adminshopId = session.query(AdminShop.id)\
                .filter(AdminShop.shop_id ==adminshop.shop_id, AdminShop.admin_id == adminshop.admin_id, AdminShop.shop_type == adminshop.shop_type).scalar()
            if adminshopId:
                pass
            else:
                session.add(adminshop)
                session.commit()
        return 1
    except:
        session.rollback()
        return -1
    finally:
        session.close()
